home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / sys5 / iscwmpst.z / iscwmpst / tcp / src / iface.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-19  |  4.8 KB  |  131 lines

  1. /* @(#) $Header: iface.h,v 1.8 91/06/18 17:27:00 deyke Exp $ */
  2.  
  3. #ifndef _IFACE_H
  4. #define _IFACE_H
  5.  
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.  
  10. #ifndef _MBUF_H
  11. #include "mbuf.h"
  12. #endif
  13.  
  14. #ifndef _PROC_H
  15. #include "proc.h"
  16. #endif
  17.  
  18. #include <stdio.h>
  19.  
  20. /* Interface control structure */
  21. struct iface {
  22.     struct iface *next;     /* Linked list pointer */
  23.     char *name;             /* Ascii string with interface name */
  24.     int type;               /* Link header type for phdr */
  25.     struct iftype *iftype;  /* Pointer to appropriate iftype entry */
  26.  
  27.     int32 addr;             /* IP address */
  28.     int32 broadcast;        /* Broadcast address */
  29.     int32 netmask;          /* Network mask */
  30.  
  31.                 /* To device -- control */
  32.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  33.                 /* From device -- when status changes */
  34.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  35.                 /* Encapsulate an IP datagram */
  36.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  37.                 /* Encapsulate any link packet */
  38.     int (*output) __ARGS((struct iface *,char *,char *,int,struct mbuf *));
  39.                 /* Send raw packet */
  40.     int (*raw) __ARGS((struct iface *,struct mbuf *));
  41.                 /* Call before detaching */
  42.     int (*stop) __ARGS((struct iface *));
  43.                 /* Display status */
  44.     int (*status) __ARGS((struct iface *));
  45.  
  46.     int16 mtu;              /* Maximum transmission unit size */
  47.     int dev;                /* Subdevice number to pass to send */
  48.     int xdev;               /* Associated Slip or Nrs channel, if any */
  49.     int16 flags;            /* Configuration flags */
  50. #define DATAGRAM_MODE   0       /* Send datagrams in raw link frames */
  51. #define CONNECT_MODE    1       /* Send datagrams in connected mode */
  52.  
  53.     int16 trace;            /* Trace flags */
  54. #define IF_TRACE_OUT    0x01    /* Output packets */
  55. #define IF_TRACE_IN     0x10    /* Packets to me except broadcast */
  56. #define IF_TRACE_ASCII  0x100   /* Dump packets in ascii */
  57. #define IF_TRACE_HEX    0x200   /* Dump packets in hex/ascii */
  58. #define IF_TRACE_NOBC   0x1000  /* Suppress broadcasts */
  59. #define IF_TRACE_RAW    0x2000  /* Raw dump, if supported */
  60.     char *trfile;           /* Trace file name, if any */
  61.     FILE *trfp;             /* Stream to trace to */
  62.  
  63.     char *hwaddr;           /* Device hardware address, if any */
  64.     struct iface *forw;     /* Forwarding interface for output, if rx only */
  65.  
  66.     int32 ipsndcnt;         /* IP datagrams sent */
  67.     int32 rawsndcnt;        /* Raw packets sent */
  68.     int32 iprecvcnt;        /* IP datagrams received */
  69.     int32 rawrecvcnt;       /* Raw packets received */
  70.     int32 lastsent;         /* Clock time of last send */
  71.     int32 lastrecv;         /* Clock time of last receive */
  72.  
  73.     void (*rxproc) __ARGS((struct iface *)); /* Receiver process, if any */
  74.     struct proc *txproc;    /* Transmitter process, if any */
  75.     struct proc *supv;      /* Supervisory process, if any */
  76.     int sendcrc;            /* Send CRC if true (KISS only) */
  77.     int32 crcerrors;        /* Packets received with CRC errors (KISS only) */
  78.  
  79.     void *extension;        /* Pointer to protocol extension block, if any */
  80.  
  81.                 /* encapsulation discard */
  82.     int (*discard) __ARGS((struct iface *,struct mbuf *));
  83.                 /* encapsulation echo */
  84.     int (*echo) __ARGS((struct iface *,struct mbuf *));
  85. };
  86. #define NULLIF  (struct iface *)0
  87. extern struct iface *Ifaces;    /* Head of interface list */
  88. extern struct iface Loopback;   /* Optional loopback interface */
  89. extern struct iface Encap;      /* IP-in-IP pseudo interface */
  90.  
  91. /* Header put on front of each packet in input queue */
  92. struct phdr {
  93.     struct iface *iface;
  94.     unsigned short type;    /* Use pktdrvr "class" values */
  95. };
  96. extern char Noipaddr[];
  97. extern struct mbuf *Hopper;
  98.  
  99. /* Interface encapsulation mode table entry. An array of these structures
  100.  * are initialized in config.c with all of the information necessary
  101.  * to attach a device.
  102.  */
  103. struct iftype {
  104.     char *name;             /* Name of encapsulation technique */
  105.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  106.                 /* Routine to send an IP datagram */
  107.     int (*output) __ARGS((struct iface *,char *,char *,int,struct mbuf *));
  108.                 /* Routine to send link packet */
  109.     char *(*format) __ARGS((char *,char *));
  110.                 /* Function that formats addresses */
  111.     int (*scan) __ARGS((char *,char *));
  112.                 /* Reverse of format */
  113.     int type;               /* Type field for network process */
  114.     int hwalen;             /* Length of hardware address, if any */
  115. };
  116. #define NULLIFT (struct iftype *)0
  117. extern struct iftype Iftypes[];
  118.  
  119. /* In iface.c: */
  120. struct iface *if_lookup __ARGS((char *name));
  121. struct iface *ismyaddr __ARGS((int32 addr));
  122. int if_detach __ARGS((struct iface *ifp));
  123. int setencap __ARGS((struct iface *ifp,char *mode));
  124. char *if_name __ARGS((struct iface *ifp,char *comment));
  125. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  126.  
  127. /* In config.c: */
  128. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  129.  
  130. #endif  /* _IFACE_H */
  131.